package com.linkage.jz.bankruptcy.activity.Project;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;

import com.linkage.jz.bankruptcy.R;
import com.linkage.jz.bankruptcy.activity.Person.PersonSettingReadMeActivity;
import com.linkage.jz.bankruptcy.base.BaseActivity;
import com.linkage.jz.bankruptcy.fragment.Project.ProFlowFragment;
import com.linkage.jz.bankruptcy.fragment.Project.ProFlowSelFragment;

import java.util.ArrayList;


/**
 * @author AFAP
 * 选择节点
 */
public class SelProFlowListActivity extends BaseActivity {
    private static final String TAG = PersonSettingReadMeActivity.class.getSimpleName();

    private String mPojectId;

    private ViewPager mViewPager;
    private TabPagerAdapter mPagerAdapter;
    private ArrayList<Fragment> fragments = new ArrayList<>();

    @Override
    public void initData() {

    }

    @Override
    public void setListener() {
    }

    @Override
    public void initTitle() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_pro_flow_select);
        super.onCreate(savedInstanceState);
        titlebar_title.setText("请选择进度节点");
    }

    @Override
    public void initView() {
        mPojectId = getIntent().getStringExtra(KEY_PROJECTID);
        ProFlowSelFragment groupChildrenCollect = ProFlowSelFragment.newInstance(100, mPojectId, ProFlowFragment.ACTION_SELECT);
        fragments.add(groupChildrenCollect);
        mViewPager = this.findViewById(R.id.viewPager);
        mPagerAdapter = new TabPagerAdapter(this.getSupportFragmentManager(), fragments);

        mViewPager.setAdapter(mPagerAdapter);
        mViewPager.invalidate();
        mPagerAdapter.notifyDataSetChanged();
    }

    private class TabPagerAdapter extends FragmentStatePagerAdapter implements
            ViewPager.OnPageChangeListener {

        private ArrayList<Fragment> objects;

        public TabPagerAdapter(FragmentManager fm, ArrayList<Fragment> objects) {
            super(fm);
            this.objects = objects;
            mViewPager.setOnPageChangeListener(this);
        }

        @Override
        public Fragment getItem(int position) {
            return objects.get(position);
        }

        @Override
        public int getCount() {
            return objects.size();
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset,
                                   int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
        }
    }

}


